package com.darren.befriend;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

import com.darren.befriend.adapters.InterestPagerAdapter;
import com.darren.befriend.views.NonSwipeViewPager;


public class InterestActivity extends FragmentActivity {

	private static final int PAGE_NUMBER = 3;
	private PagerAdapter mInterestPagerAdapter;
	private NonSwipeViewPager mPager;
	private ImageView mSkipBtn;
	private ImageView mCheckBtn;
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.layout_interest);
		mSkipBtn = (ImageView) findViewById(R.id.skip_btn);
		mCheckBtn = (ImageView) findViewById(R.id.check_btn);
		mSkipBtn.setOnClickListener(mOnclickListener);
		mCheckBtn.setOnClickListener(mOnclickListener);
		mInterestPagerAdapter = new InterestPagerAdapter(getSupportFragmentManager(), PAGE_NUMBER);
		mPager = (NonSwipeViewPager) findViewById(R.id.interestPager);		
		mPager.setAdapter(mInterestPagerAdapter);		
		mPager.setOnPageChangeListener(mPageChangeListener);		
		mPager.setCurrentItem(0);
	}			
	
	OnPageChangeListener mPageChangeListener = new OnPageChangeListener() {
		
		@Override
		public void onPageSelected(int position) {
		}
		
		@Override
		public void onPageScrolled(int arg0, float arg1, int arg2) {
			
		}
		
		@Override
		public void onPageScrollStateChanged(int arg0) {
			
		}
	};
	
	OnClickListener mOnclickListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.skip_btn:
				if (mPager.getCurrentItem() > 0) {
					mPager.setCurrentItem(mPager.getCurrentItem() - 1);
				}
				break;
			case R.id.check_btn:
				if (mPager.getCurrentItem() < PAGE_NUMBER) {
					mPager.setCurrentItem(mPager.getCurrentItem() + 1);
				}
				break;
			default:
				break;
			}
		}
	};
}
